﻿<#include "/common/easyui-css.html">
<#include "/common/easyui-js.html">
<#include "/common/loading.html">
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>

<body class="easyui-layout">
<div data-options="region:'center',border:false" style="height: auto">
    <table id="constant_table" class="easyui-datagrid" title="" style="width:100%;height:100%;padding-bottom: 2px;"
                   data-options="rownumbers:true, pagination:true,singleSelect:true,
                              url:'/constant-list/1/20',
                              method:'get',
                              toolbar:'#tb',
                              loadMsg : '数据加载中',
                              fitColumns : true,
                              showFooter: true" >
            <thead>
                <tr>
                    <th data-options="field:'constantKey', width:90" >常量索引</th>
                    <th data-options="field:'constantKeyDesc', width:90" >常量索引描述</th>
                    <th data-options="field:'constantValue', width:90">常量值</th>
                    <th data-options="field:'constantValueDesc', width:90">常量值描述</th>
                </tr>
            </thead>
    </table>
</div>
<!-- 搜索框 -->
<div id="tb" style="padding:5px;height:auto">
	<div>
        常量索引:<input class="easyui-textbox" id="to" style="width:120px" >
		<a href="#" class="easyui-linkbutton" iconCls="icon-search" id="searchByParameter">搜索</a>
	</div>
    <div style="margin:5px 0;"></div>
    <#include "/common/button.html">
</div>

<!-- 新增、编辑弹出框 -->
<div id="dlg" class="easyui-dialog" style="width:600px" data-options="closed:true,modal:true,border:'thin',buttons:'#dlg-buttons'">
    <form id="fm" method="post" novalidate style="margin:0;padding:20px 50px">
        <div style="margin-bottom:10px">
            <input name="constantKey" class="easyui-textbox" required="true" label="常量索引:" style="width:100%">
        </div>
        <div style="margin-bottom:10px">
            <input name="constantKeyDesc" class="easyui-textbox" required="true" label="常量索引描述:" style="width:100%">
        </div>
        <div style="margin-bottom:10px">
            <input name="constantValue" class="easyui-textbox" required="true" label="常量值:" style="width:100%">
        </div>
        <div style="margin-bottom:10px">
            <input name="constantValueDesc" class="easyui-textbox" required="true" label="常量值描述:" style="width:100%">
        </div>
    </form>
</div>
<div id="dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveConstant()" style="width:90px">Save</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
</div>

<!-- 按钮操作 -->
<script type="text/javascript">
    var url;
    //新增
    $("#add").click(function () {
        $('#dlg').dialog('open').dialog('center').dialog('setTitle','新增角色');
        $('#fm').form('clear');
        url = '/constant-ins-upd-del/-1';
    });

    //保存
    function saveConstant(){
        $('#fm').form('submit',{
            url: url,
            onSubmit: function(){
                return $(this).form('validate');
            },
            success: function(result){
                $('#dlg').dialog('close');        // close the dialog
                $('#constant_table').datagrid('reload');    // reload the user data
            }
        });
    }

    //编辑
    $("#edit").click(function () {
        var row = $('#constant_table').datagrid('getSelected');
        if (row){
            $('#dlg').dialog('open').dialog('center').dialog('setTitle','编辑');
            $('#fm').form('load',row);
            url = '/constant-ins-upd-del/'+row.id;
        } else {
            layer.msg("请选择需要编辑的常量",{icon: 2})
        }
    });

    // 行复制
    $('#copy').click(function(){
        var row = $('#constant_table').datagrid('getSelected');
        if (row){
            $('#dlg').dialog('open').dialog('center').dialog('setTitle','行复制');
            $('#fm').form('load',row);
            url = '/constant-ins-upd-del/-1';
        } else {
            layer.msg("请选择需要复制行",{icon: 2})
        }
    });

    //删除
    $("#delete").click(function () {
        var row = $('#constant_table').datagrid('getSelected');
        if(!row){
            layer.msg("请选择需要删除的常量",{icon: 2})
        }else{
            url = '/constant-ins-upd-del/'+row.id;
            $.messager.confirm('删除信息','确定删除常量?',function(r){
                if (r){
                    $.post(url,{deleteFlag:'Y',tm:new Date()},function(result){
                        $('#constant_table').datagrid('reload');    // reload the user data
                    });
                }
            });
        }
    })
</script>


<!-- 分页 -->
<script type="text/javascript">
	$(function(){
		var p = $('#constant_table').datagrid().datagrid('getPager');
		p.pagination({
			pageSize: 20, //每页显示的记录条数，默认为10
			pageList: [20, 40, 60], //可以设置每页记录条数的列表
			onSelectPage: function (pageNumber, pageSize) {
			    if(pageNumber==0){
			        pageNumber = 1;
                }
				var handler = '/constant-list/'+pageNumber+"/"+pageSize;
				$('#constant_table').datagrid('options').url = handler;
				$('#constant_table').datagrid('reload');
			}
		});
	})
</script>
